package com.global.college.api;


import com.global.college.data.net.CourseDetailBean;
import com.global.college.data.net.CourseVideosBean;
import com.global.college.data.net.HomeGoodListBean;
import com.global.college.data.net.MyCourseListBean;
import com.global.college.data.net.MyTrainListBean;
import com.global.college.data.net.TagListBean;
import com.global.college.data.net.TrainBannerBean;
import com.global.college.data.net.TrainDetailBean;
import com.global.college.data.net.TrainStageBean;
import com.global.college.data.net.VersionBean;
import com.global.college.data.net.VideoDetailBean;
import com.global.college.data.net.VideoHistoryBean;
import com.global.college.ui.bean.GoodsDetailModel;
import com.global.college.ui.bean.MyOrderDetail;
import com.global.college.ui.bean.MyOrderListModel;
import com.global.college.ui.bean.OrderCreateModel;
import com.global.college.ui.bean.TokenModel;
import com.global.college.ui.bean.WxPayModel;

import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.POST;
import retrofit2.http.Query;
import rx.Observable;

/**
 * Created by fu on 2020/2/18.
 * Describe: 请求封装（服务端要求请求体同意使用json，故使用requestBody请求体）
 */
public interface ServerAPI {

    /**
     *

     * @return
     */
    @POST(URLs.GET_GOOD_LIST)
    Observable<HttpResult<HomeGoodListBean>> getGoodList(@Body RequestBody body);

    @GET(URLs.GET_TAG_LIST)
    Observable<HttpResult<TagListBean[]>> getTagList();

    @GET(URLs.GET_TRAIN_COURSE)
    Observable<HttpResult<TrainStageBean[]>> getTrainList(@Query("trainingId")String traingId);

    @GET(URLs.GET_TRAIN_BANNER)
    Observable<HttpResult<TrainBannerBean>> getTrainBanner(@Query("trainingId")String traingId,@Query("userId")String userId);

    @GET(URLs.GET_COURSE_VIDEOS)
    Observable<HttpResult<CourseVideosBean[]>> getCourseVideos(@Query("classId")String classId);

    @GET(URLs.GET_VIDEO_DETAIL)
    Observable<HttpResult<VideoDetailBean>> getVideoDetail(@Query("videoId")String videoId);

    @GET(URLs.GET_TRAIN_DETAIL)
    Observable<HttpResult<TrainDetailBean>> getTrainDetail(@Query("trainingId")String trainId, @Query("userId")String userId);

    @POST(URLs.GET_WX_TOKEN)
    Observable<HttpResult<TokenModel>> getWxToken(@Header("source") String source, @Header("Authorization") String token, @Body RequestBody body);

    @POST(URLs.BIND_PHONE)
    Observable<HttpResult<TokenModel>> bindPhone(@Header("source") String source, @Body RequestBody body);

    @POST(URLs.UNBIND_WX)
    Observable<HttpResult<BaseResponseModel>> unbindWx(@Header("Authorization") String token);

    @POST(URLs.BIND_WX)
    Observable<HttpResult<BaseResponseModel>> bindWx(@Header("Authorization") String token, @Body RequestBody body);

    /**
     * 9.用户订单
     * Authorization
     * userId	用户id
     * orderState	订单状态 默认  0 未支付，1 支付完成，2 取消的，不传默认查询当前用户所有订单
     * pageNum	第几页
     * pageSize	 一页多少条
     */
    @GET(URLs.MY_ORDER_LIST)
    Observable<HttpResult<MyOrderListModel>> getOrderList(@Header("Authorization") String token, @Query("userId")String userId, @Query("orderState")String orderState, @Query("pageNum")int pageNum, @Query("pageSize")int pageSize);
    /**
     * 10.我的课程 分页列表
     * Authorization
     * pageNum
     * pageSize
     * type	0全部  1学习中  2已完成(int)
     */
    @GET(URLs.MY_COURSE_LIST)
    Observable<HttpResult<MyCourseListBean>> getCourseList(@Header("Authorization") String token, @Query("pageNum")int pageNum, @Query("pageSize")int pageSize, @Query("type")int type);
    /**
     * 11.我的课程 课程详情
     * Authorization
     * classId	课程id(String)
     */
    @GET(URLs.MY_COURSE_DETAIL)
    Observable<HttpResult<Object>> getCourseDetail(@Header("Authorization") String token,@Query("classId")String classId);

    /**
     * 12.我的训练营 分页列表
     * Authorization
     * pageNum
     * pageSize
     * type	0全部  1学习中  2已完成(int)
     */
    @GET(URLs.MY_TRAINING_LIST)
    Observable<HttpResult<MyTrainListBean>> getTraningList(@Header("Authorization") String token, @Query("pageNum")int pageNum, @Query("pageSize")int pageSize, @Query("type")int type);

    /**
     * 13.我的训练营 训练营详情
     * Authorization
     * trainingId
     */
    @GET(URLs.MY_TRAINING_DETAIL)
    Observable<HttpResult<Object>> getTraningDetail(@Header("Authorization") String token,@Query("trainingId")String trainingId);
    /**
     * 14.创建订单
     * Authorization
     * userId	用户id
     * goodId	商品id，商品列表获取的一大串字符串那个
     * source	来源
     */
    @POST(URLs.CREATE_ORDER)
    Observable<HttpResult<OrderCreateModel>> createOrder(@Header("Authorization") String token, @Body RequestBody body);
    /**
     * 15.取消订单
     * Authorization
     * orderId	订单ID  一大串字符串那个
     */
    @POST(URLs.CANCLE_ORDER)
    Observable<HttpResult<Object>> cancleOrder(@Header("Authorization") String token,@Body RequestBody body);
    /**
     * 16.支付回调
     * Authorization
     * paymentType	 支付渠道
     * notifyTime	通知时间
     * businessOrderNo	业务平台订单号
     * paymentTradeNo	支付平台流水号
     * tradeStatus	交易状态
     * totalAmount	订单金额
     * receiptAmount	实际金额
     * subject	标题。由商户定义的
     * gmtCreate	交易创建时间
     * gmtPayment	交易付款时间
     * gmtRefund	交易退款时间
     * gmtClose	交易结束时间
     * passbackParams	回传参数商户定义的
     */
    @POST(URLs.PAY_CALLBACK)
    Observable<HttpResult<Object>> payCallBack(@Header("Authorization") String token,@Body RequestBody body);
    /**
     * 17.商品 课程详情
     * Authorization
     * goodId
     */
    @GET(URLs.GOODS_DETAIL)
    Observable<HttpResult<GoodsDetailModel>> getGoodsDetail(@Header("Authorization") String token, @Query("goodId")String goodId);
    /**
     * 18.订单详情
     *
     * Authorization
     * orderId
     */
    @GET(URLs.ORDER_DETAIL)
    Observable<HttpResult<MyOrderDetail>> getOrderDetail(@Header("Authorization") String token, @Query("orderId")String orderId);

    /**
     * 19.微信支付v2版本 发起微信支付请求
     * body	商品描述
     * outTradeNo	 商户订单号
     * totalFee	订单总金额（元）
     * tradeType	交易类型,JSAPI支付,Native支付APP支付，MWEB H5支付
     * productId	产品id  当tradeType=Native 的时候必须带上productId
     * timeExpire	交易结束时间/订单失效时间 默认2小时,格式为yyyyMMddHHmmss，如2009年12月25日9点10分10秒表示为20091225091010
     * appId	默认uton在线 appid可不传，nft和其他调用必传appid
     */
    @POST(URLs.WECHAT_PAY)
    Observable<HttpResult<WxPayModel>> wxPay(@Header("Authorization") String token, @Body RequestBody body);
    /**
     * 20.发起支付宝支付
     * orderNo	订单号
     * totalAmount	订单支付金额
     * subject	商品标题
     * paySkillName	支付能力名称,取值： APP,或者 PC
     * returnUrl	回调地址
     */
    @POST(URLs.ALI_PAY)
    Observable<HttpResult<String>> aliPay(@Header("Authorization") String token, @Body RequestBody body);

    @GET(URLs.GET_COURSE_DETAIL)
    Observable<HttpResult<CourseDetailBean>> getCourseDetail(@Query("goodId")String goodId);

    @POST(URLs.SAVE_VIDEO_HISTORY)
    Observable<HttpResult<Object>> saveVideoHistory(@Body RequestBody body);

    @GET(URLs.GET_VIDEO_HISTORY)
    Observable<HttpResult<VideoHistoryBean>> getVideoHistory(@Query("userId")String userId, @Query("trainingId")String trainId, @Query("classId")String classId);

    @GET(URLs.GET_MY_COURSE_DETAIL)
    Observable<HttpResult<CourseDetailBean>> getMyCourseDetail(@Query("classId")String classId);

    @GET(URLs.GET_VERSION_INFO)
    Observable<HttpResult<VersionBean>> getVersionInfo(@Query("configKey")String classId);

}